﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace ShellLight
{
    public partial class ModalWindow : ChildWindow
    {
        public ModalWindow()
        {
            InitializeComponent();
            this.Closing += ModalWindow_Closing;
            this.KeyDown += ModalWindow_KeyDown;
        }

        public ModalWindow(UIElement view, string title):this()
        {
            Content.Content = view;
            Title = title;
        }

        void ModalWindow_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                this.Close();
            }
        }

        void ModalWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Content.Content = null;
        }
    }
}

